Counting Base \(b\) Digits

Theorem

Let \(n \in \mathbb{Z}^+\). The base \(b\) expansion of \(n\) has exactly \(\lfloor \log_b (n) \rfloor + 1\) digits.

Proof

If \(n\) has \(d\) digits in base \(b\), then it satisfies

\[ b^{d - 1} \leq n < b^d\]

because it has a unique base \(b\) expansion as

\[ n = a_0 + a_1 b + \dots a_{d - 1} b^{d - 1}\]

where \(0 \leq a_i < b\) and \(a_{d - 1} \neq 0\). That is, it is at least the smallest \(d\) digit number and less than the smallest \(d + 1\) digit number.

Since \(\log_b\) is a strictly increasing function, we have

\[ d - 1 = \log_b(b^{d - 1}) \leq \log_b(n) < \log_b(b^d) = d.\]

Being squeezed between consecutive integers, we conclude that \(d - 1 = \lfloor \log_b(n) \rfloor\) and thus \(d = \lfloor \log_b(n) \rfloor + 1\).